using System.Collections;
using UnityEngine;
using UnityEngine.Events;

namespace WorkFlow.TweenGo
{
    public class TweenSleep : MonoBehaviour
    {
        [SerializeField] float playSleepTime = 0.5f;
        [SerializeField] private UnityEvent onPlay = new UnityEvent();

        public void Play()
        {
            if (playSleepTime == 0)
            {
                onPlay?.Invoke();
            }
            else
            {
                StartCoroutine(OnStart());
            }
        }

        IEnumerator OnStart()
        {
            yield return new WaitForSeconds(playSleepTime);
            onPlay?.Invoke();
        }
    }
}